package app.myproject.dao;

import java.util.List;

import app.myproject.model.NotificationVO;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

public class NotificationDAOImpl extends AbstractDAOImpl<NotificationVO, Key> {

	public NotificationDAOImpl() {
		super(NotificationVO.class);
	}

	public NotificationVO find(String encodedKey) {
		if (encodedKey != null) {
			Key key = KeyFactory.stringToKey(encodedKey);
			return super.find(key);
		}
		return null;
	}
	
	public NotificationVO findByName(String name) {
		List<NotificationVO> results = list("name",name);
		if (!results.isEmpty()) 
			return results.get(0);
		
		return null;
	}
	
	public void deleteById(String encodedKey) {
		Key key = KeyFactory.stringToKey(encodedKey);
		super.deleteById(key);
	}

}
